#include "conf.h"

int *video_quality = &conf.video_quality;
int *video_mode    = &conf.video_mode;

long def_table1[9]={0x2000,0x38D,0x788,0x5800,0x9C5,0x14B8,0x10000,0x1C6A,0x3C45};
long def_table2[9]={0x1CCD,-0x2E1,-0x579,0x4F33,-0x7EB,-0xF0C,0xE666,-0x170A,-0x2BC6};

long table1[9], table2[9];

void change_video_tables(int a, int b){
 int i;
 for (i=0;i<9;i++) {table1[i]=(def_table1[i]*a)/b; table2[i]=(def_table2[i]*a)/b;}
}

long CompressionRateTable[]={0x60, 0x5D, 0x5A, 0x57, 0x54, 0x51, 0x4D, 0x48, 0x42, 0x3B, 0x32, 0x29, 0x22, 0x1D, 0x17, 0x14, 0x10, 0xE, 0xB, 9, 7, 6, 5, 4, 3, 2, 1};


void __attribute__((naked,noinline)) movie_record_task(){
 asm volatile(
                "STMFD   SP!, {R4,LR}\n"              
                "SUB     SP, SP, #4\n"                
                "MOV     R4, SP\n"                    
                "B       loc_FFD3B4C8\n"              
"loc_FFD3B424:\n"                                     
                "LDR     R3, =0x6E460\n"              
                "LDR     R2, [R3]\n"                  
                "CMP     R2, #0\n"                    
                "BNE     loc_FFD3B4B4\n"              
                "SUB     R3, R12, #2\n"               
                "CMP     R3, #9\n"                    
                "LDRLS   PC, [PC,R3,LSL#2]\n"         
                "B       loc_FFD3B4B4\n"              
                ".long loc_FFD3B474\n"
                ".long loc_FFD3B48C\n"
                ".long loc_FFD3B494\n"
                ".long loc_FFD3B49C\n"
                ".long loc_FFD3B47C\n"
                ".long loc_FFD3B4A4\n"
                ".long loc_FFD3B484\n"
                ".long loc_FFD3B4B4\n"
                ".long loc_FFD3B4AC\n"
                ".long loc_FFD3B46C\n"
"loc_FFD3B46C:\n"                                     
                                                  
                "BL      sub_FFD3B560\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B474:\n"
       
                "BL      unlock_optical_zoom\n"                                 
                "BL      sub_FFD3B714\n"  
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B47C:\n"                                     
                                                  
                "BL      sub_FFD3BAE8_my\n"   //--------------->           
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B484:\n"                                     
                                                  
                "BL      sub_FFD3BF1C\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B48C:\n"                                     
                                                  
                "BL      sub_FFD3BD80\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B494:\n"                                     
                                                  
                "BL      sub_FFD3C08C\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B49C:\n"                                     
                                                  
                "BL      sub_FFD3C250\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B4A4:\n"                                     
                                                  
                "BL      sub_FFD3BFA4\n"              
                "B       loc_FFD3B4B0\n"              
"loc_FFD3B4AC:\n"                                     
                                                  
                "BL      sub_FFD3BDD0\n"              
"loc_FFD3B4B0:\n"                                     
                                                  
                "LDR     R1, [SP]\n"                  
"loc_FFD3B4B4:\n"                                     
                                                  
                "LDR     R3, =0x6E394\n"              
                "MOV     R2, #0\n"                    
                "STR     R2, [R1]\n"                  
                "LDR     R0, [R3]\n"                  
                "BL      sub_FFC104D8\n"          
"loc_FFD3B4C8:\n"                                     
                "LDR     R3, =0x6E390\n"              
                "MOV     R1, R4\n"                    
                "LDR     R0, [R3]\n"                  
                "MOV     R2, #0\n"                    
                "BL      sub_FFC100C0\n"       
                "LDR     R0, [SP]\n"                  
                "LDR     R12, [R0]\n"                 
                "CMP     R12, #0xC\n"                 
                "MOV     R1, R0\n"                    
                "BNE     loc_FFD3B424\n"              
                "LDR     R3, =0x6E38C\n"              
                "LDR     R0, [R3]\n"                  
                "BL      sub_FFC10E54\n"             
                "BL      sub_FFC1161C\n"                  
                "ADD     SP, SP, #4\n"                
                "LDMFD   SP!, {R4,PC}\n"              
 );
}




void __attribute__((naked,noinline)) sub_FFD3BAE8_my(){
 asm volatile(
                "STMFD   SP!, {R4-R11,LR}\n"          
                "LDR     R5, =0x6E47C\n"              
                "SUB     SP, SP, #0x34\n"             
                "LDR     R3, [R5]\n"                  
                "CMP     R3, #3\n"                    
                "MOV     R4, R0\n"                    
                "MOVEQ   R3, #4\n"                    
                "STREQ   R3, [R5]\n"                  
                "LDR     R3, =0x6E52C\n"              
                "MOV     LR, PC\n"                    
                "LDR     PC, [R3]\n"                  
                "LDR     R2, [R5]\n"                  
                "CMP     R2, #4\n"                    
                "BNE     loc_FFD3BCAC\n"              
                "ADD     R0, SP, #0x30\n"             
                "ADD     R1, SP, #0x2C\n"             
                "ADD     R2, SP, #0x28\n"             
                "ADD     R3, SP, #0x24\n"             
                "BL      sub_FFD3D1BC_my\n"   //--------------------->          
                "CMP     R0, #0\n"                    
                "BNE     loc_FFD3BB64\n"              
                "LDR     R3, =0x6E468\n"              
                "LDR     R2, [R3]\n"                  
                "CMP     R2, #1\n"                    
                "BNE     loc_FFD3BB78\n"              
                "LDR     R2, =0x6E4C0\n"              
                "LDR     R1, =0x6E494\n"              
                "LDR     R12, [R2]\n"                 
                "LDR     R3, [R1]\n"                  
                "CMP     R12, R3\n"                   
                "BCC     loc_FFD3BB78\n"              
"loc_FFD3BB64:\n"                                     
                "BL      sub_FFD3BCF8\n"              
                "BL      sub_FFD3BEF8\n"              
                "MOV     R3, #5\n"                    
                "STR     R3, [R5]\n"                  
                "B       loc_FFD3BCAC\n"              
"loc_FFD3BB78:\n"                                     
                                                  
                "LDR     R12, =0x6E4C8\n"             
                "LDR     R11, =0x6E4D4\n"             
                "LDMIB   R4, {R0-R2}\n"               
                "LDR     R10, [R12]\n"                
                "LDR     R7, [R11]\n"                 
                "LDR     R4, [SP,#0x2C]\n"            
                "LDR     R5, [SP,#0x28]\n"            
                "LDR     R6, [SP,#0x24]\n"            
                "LDR     R8, =0x6E46C\n"              
                "LDR     R3, [SP,#0x30]\n"            
                "ADD     R12, SP, #0x20\n"            
                "ADD     LR, SP, #0x1C\n"             
                "MOV     R9, #1\n"                    
                "STMEA   SP, {R4-R6,R12}\n"           
                "STR     R10, [SP,#0x10]\n"           
                "STR     R7, [SP,#0x14]\n"            
                "STR     LR, [SP,#0x18]\n"            
                "STR     R9, [R8]\n"                  
                "BL      sub_FFC84328\n"              
                "LDR     R3, =0x6E384\n"              
                "MOV     R1, #0x3E8\n"                
                "LDR     R0, [R3]\n"                  
                "BL      sub_FFC10C6C\n"             
                "CMP     R0, #9\n"                    
                "BNE     loc_FFD3BBEC\n"              
                "BL      sub_FFD3D9CC\n"              
                "LDR     R3, =0x6E47C\n"              
                "LDR     R0, =0xFFD3BAD0\n"       
                "B       loc_FFD3BC04\n"              
"loc_FFD3BBEC:\n"                                     
                "LDR     R5, [SP,#0x1C]\n"            
                "CMP     R5, #0\n"                    
                "BEQ     loc_FFD3BC10\n"              
                "BL      sub_FFD3D9CC\n"              
                "LDR     R3, =0x6E47C\n"              
                "LDR     R0, =0xFFD3BADC\n"       
"loc_FFD3BC04:\n"                                     
                "STR     R9, [R3]\n"                  
                "BL      sub_FFD50948\n"              
                "B       loc_FFD3BCAC\n"              
"loc_FFD3BC10:\n"                                     
                "BL      sub_FFC84494\n"              
                "LDR     R0, [SP,#0x30]\n"            
                "LDR     R1, [SP,#0x20]\n"            
                "BL      sub_FFD3D6F0\n"              
                "LDR     R4, =0x6E4C0\n"              
                "LDR     R3, [R4]\n"                  
                "ADD     R3, R3, #1\n"                
                "LDR     R0, [SP,#0x20]\n"            
                "MOV     R1, R11\n"                   
                "STR     R3, [R4]\n"                  
                "MOV     R2, R5\n"                    
                "BL      sub_FFD3C5AC_my\n"    //---------------------->          
                "LDR     R3, =0x6E4E0\n"              
                "LDR     R1, [R4]\n"                  
                "LDR     R2, [R3]\n"                  
                "LDR     R12, =0x6E4DC\n"             
                "MUL     R0, R2, R1\n"                
                "LDR     R1, [R12]\n"                 
                "BL      sub_FFEDC0F0\n"                 
                "LDR     R7, =0x6E4D8\n"              
                "LDR     R3, [R7]\n"                  
                "MOV     R4, R0\n"                    
                "CMP     R3, R4\n"                    
                "BNE     loc_FFD3BC84\n"              
                "LDR     R6, =0x6E470\n"              
                "LDR     R3, [R6]\n"                  
                "CMP     R3, #1\n"                    
                "BNE     loc_FFD3BCA0\n"              
                "B       loc_FFD3BC88\n"              
"loc_FFD3BC84:\n"                                     
                "LDR     R6, =0x6E470\n"              
"loc_FFD3BC88:\n"                                     
                "LDR     R3, =0x6E510\n"              
                "MOV     R0, R4\n"                    
                "MOV     LR, PC\n"                    
                "LDR     PC, [R3]\n"                  
                "STR     R5, [R6]\n"                  
                "STR     R4, [R7]\n"                  
"loc_FFD3BCA0:\n"                                     
                "LDR     R2, =0x6E46C\n"              
                "MOV     R3, #0\n"                    
                "STR     R3, [R2]\n"                  
"loc_FFD3BCAC:\n"                                     
                                                  
                "ADD     SP, SP, #0x34\n"             
                "LDMFD   SP!, {R4-R11,PC}\n"          

 );
}


void __attribute__((naked,noinline)) sub_FFD3D1BC_my(){
 asm volatile(
                "STMFD   SP!, {R4-R11,LR}\n"          
                "LDR     R5, =0x6E7D4\n"              
                "SUB     SP, SP, #0x14\n"             
                "LDR     LR, [R5]\n"                  
                "LDR     R12, =0x6E7EC\n"             
                "ADD     LR, LR, #1\n"                
                "LDR     R4, [R12]\n"                 
                "STR     LR, [R5]\n"                  
                "LDR     R12, =0x6E86C\n"             
                "STR     R0, [SP,#0x10]\n"            
                "STR     R1, [SP,#0xC]\n"             
                "STR     R2, [SP,#8]\n"               
                "STR     R3, [SP,#4]\n"               
                "CMP     LR, R4\n"                    
                "LDR     R11, [R12]\n"                
                "MOVHI   R0, #0x80000001\n"           
                "BHI     loc_FFD3D6A4\n"              
                "LDR     R3, =0x6E850\n"              
                "MOV     R0, LR\n"                    
                "LDR     R1, [R3]\n"                  
                "BL      sub_FFEDC780\n"                 
                "CMP     R0, #1\n"                    
                "BNE     loc_FFD3D3DC\n"              
                "LDR     R0, =0x6E874\n"              
                "LDR     R1, =0x6E7C0\n"              
                "LDR     R3, [R0]\n"                  
                "LDR     R2, [R1]\n"                  
                "CMP     R3, R2\n"   	                 
                "LDREQ   R3, =0x6E870\n"              
                "LDREQ   R5, [R3]\n"                  
                "MOVNE   R5, R2\n"                    
                "LDR     R3, =0x6E7D4\n"              
                "LDR     R2, =0x6E850\n"              
                "LDR     R0, [R3]\n"                  
                "LDR     R1, [R2]\n"                  
                "BL      sub_FFEDC0F0\n"                 
                "LDR     R3, =0x6E7C8\n"              
                "ADD     R0, R0, #1\n"                
                "AND     R0, R0, #1\n"                
                "STR     R5, [R3,R0,LSL#2]\n"         
                "LDR     R3, =0x6E7BC\n"              
                "LDR     R2, [R3]\n"                  
                "CMP     R5, R2\n"                    
                "BHI     loc_FFD3D28C\n"              
                "LDR     R4, =0x6E80C\n"              
                "LDR     R3, [R4]\n"                  
                "ADD     R3, R5, R3\n"                
                "ADD     R3, R3, #8\n"                
                "CMP     R2, R3\n"                    
                "BCS     loc_FFD3D290\n"              
"loc_FFD3D284:\n"                                     
                                                  
                "MOV     R0, #0x80000003\n"           
                "B       loc_FFD3D6A4\n"              
"loc_FFD3D28C:\n"                                     
                "LDR     R4, =0x6E80C\n"              
"loc_FFD3D290:\n"                                     
                "LDR     R3, [R4]\n"                  
                "LDR     R2, =0x6E874\n"              
                "ADD     R1, R5, R3\n"                
                "LDR     R3, [R2]\n"                  
                "ADD     R2, R1, #8\n"                
                "CMP     R2, R3\n"                    
                "BLS     loc_FFD3D2DC\n"              
                "LDR     R2, =0x6E870\n"              
                "LDR     R0, =0x6E7BC\n"              
                "RSB     R3, R3, R1\n"                
                "LDR     R1, [R2]\n"                  
                "ADD     R3, R3, #8\n"                
                "LDR     R2, [R0]\n"                  
                "ADD     R1, R1, R3\n"                
                "CMP     R2, R1\n"                    
                "BCC     loc_FFD3D284\n"              
                "LDR     R3, =0x6E7C0\n"              
                "STR     R1, [R3]\n"                  
                "B       loc_FFD3D2E4\n"              
"loc_FFD3D2DC:\n"                                     
                "LDR     R3, =0x6E7C0\n"              
                "STR     R2, [R3]\n"                  
"loc_FFD3D2E4:\n"                                     
                "LDR     R3, [R4]\n"                  
                "LDR     R12, =0x6E820\n"             
                "ADD     R3, R3, #0x18\n"             
                "LDR     R2, [R12,#4]\n"              
                "MOV     R0, R3\n"                    
                "MOV     R1, #0\n"                    
                "CMP     R1, R2\n"                    
                "BHI     loc_FFD3D528\n"              
                "BNE     loc_FFD3D314\n"              
                "LDR     R3, [R12]\n"                 
                "CMP     R0, R3\n"                    
                "BHI     loc_FFD3D528\n"              
"loc_FFD3D314:\n"                                     
                "LDR     R4, [R4]\n"                  
                "LDR     LR, =0x6E828\n"              
                "STR     R4, [SP]\n"                  
                "LDR     R12, =0x6E820\n"             
                "LDR     R3, =0x6E7D4\n"              
                "LDMIA   LR, {R7,R8}\n"               
                "LDMIA   R12, {R5,R6}\n"              
                "LDR     R10, [R3]\n"                 
                "LDR     R2, =0x6E850\n"              
                "MOV     R3, R4\n"                    
                "MOV     R4, #0\n"                    
                "ADDS    R7, R7, R3\n"                
                "ADC     R8, R8, R4\n"                
                "LDR     R9, [R2]\n"                  
                "SUBS    R5, R5, R3\n"                
                "SBC     R6, R6, R4\n"                
                "MVN     R2, #0\n"                    
                "MVN     R1, #0x17\n"                 
                "ADDS    R5, R5, R1\n"                
                "MOV     R4, #0\n"                    
                "MOV     R3, #0x18\n"                 
                "ADC     R6, R6, R2\n"                
                "ADDS    R7, R7, R3\n"                
                "ADC     R8, R8, R4\n"                
                "STMIA   R12, {R5,R6}\n"              
                "SUB     R0, R10, #1\n"               
                "MOV     R1, R9\n"                    
                "STMIA   LR, {R7,R8}\n"               
                "BL      sub_FFEDC0F0\n"                 
                "CMP     R10, #1\n"                   
                "MLA     R0, R9, R0, R0\n"            
                "BEQ     loc_FFD3D3DC\n"              
                "SUB     R3, R0, #1\n"                
                "MOV     R3, R3,LSL#4\n"              
                "ADD     R4, R11, #0x10\n"            
                "ADD     R5, R11, #0x14\n"            
                "LDR     R1, [R5,R3]\n"               
                "LDR     R2, [R4,R3]\n"               
                "LDR     LR, =0x62773130\n"           
                "ADD     R2, R2, R1\n"                
                "MOV     R3, R0,LSL#4\n"              
                "ADD     R2, R2, #8\n"                
                "MOV     R0, #0\n"                    
                "ADD     R12, R11, #0xC\n"            
                "ADD     R1, R11, #8\n"               
                "STR     LR, [R1,R3]\n"               
                "STR     R0, [R12,R3]\n"              
                "STR     R2, [R4,R3]\n"               
                "LDR     R0, [SP]\n"                  
                "STR     R0, [R5,R3]\n"               
"loc_FFD3D3DC:\n"                                     
                                                  
                "LDR     R2, =0x6E7C0\n"              
                "LDR     R3, =0x6E874\n"              
                "LDR     R1, [R2]\n"                  
                "LDR     R0, [R3]\n"                  
                "ADD     R3, R1, #9\n"                
                "CMP     R3, R0\n"                    
                "BLS     loc_FFD3D418\n"              
                "LDR     R2, =0x6E870\n"              
                "LDR     R3, [R2]\n"                  
                "ADD     R3, R3, R1\n"                
                "RSB     R3, R0, R3\n"                
                "LDR     R0, [SP,#0x10]\n"            
                "ADD     R3, R3, #8\n"                
                "STR     R3, [R0]\n"                  
                "B       loc_FFD3D424\n"              
"loc_FFD3D418:\n"                                     
                "ADD     R3, R1, #8\n"                
                "LDR     R1, [SP,#0x10]\n"            
                "STR     R3, [R1]\n"                  
"loc_FFD3D424:\n"                                     
                "LDR     R2, [SP,#0x10]\n"            
                "LDR     R1, =0x6E81C\n"              
                "LDR     R3, =0x6E874\n"              
                "LDR     R12, [R2]\n"                 
                "LDR     R2, [R1]\n"                  
                "LDR     R0, [R3]\n"                  
                "ADD     R3, R12, R2\n"               
                "CMP     R3, R0\n"                    
                "BLS     loc_FFD3D478\n"              
                "LDR     R2, [SP,#0xC]\n"             
                "RSB     R0, R12, R0\n"               
                "STR     R0, [R2]\n"                  
                "LDR     R2, =0x6E870\n"              
                "LDR     R3, [R1]\n"                  
                "LDR     R1, [R2]\n"                  
                "RSB     R3, R0, R3\n"                
                "LDR     R0, [SP,#8]\n"               
                "STR     R1, [R0]\n"                  
                "LDR     R1, [SP,#4]\n"               
                "STR     R3, [R1]\n"                  
                "B       loc_FFD3D494\n"              
"loc_FFD3D478:\n"                                     
                "LDR     R0, [SP,#0xC]\n"             
                "STR     R2, [R0]\n"                  
                "LDR     R1, [SP,#4]\n"               
                "MOV     R3, #0\n"                    
                "STR     R3, [R1]\n"                  
                "LDR     R2, [SP,#8]\n"               
                "STR     R3, [R2]\n"                  
"loc_FFD3D494:\n"                                     
                "LDR     R0, =0x6E7C0\n"              
                "LDR     R1, =0x6E7BC\n"              
                "LDR     R3, [R0]\n"                  
                "LDR     R2, [R1]\n"                  
                "CMP     R3, R2\n"                    
                "BHI     loc_FFD3D4C0\n"              
                "LDR     R0, [SP,#0xC]\n"             
                "LDR     R3, [R0]\n"                  
                "ADD     R3, R12, R3\n"               
                "CMP     R2, R3\n"                    
                "BCC     loc_FFD3D284\n"              
"loc_FFD3D4C0:\n"                                     
                "LDR     R1, [SP,#8]\n"               
                "LDR     R2, [R1]\n"                  
                "CMP     R2, #0\n"                    
                "BEQ     loc_FFD3D4F4\n"              
                "LDR     R3, =0x6E7BC\n"              
                "LDR     R1, [R3]\n"                  
                "CMP     R2, R1\n"                    
                "BHI     loc_FFD3D4F4\n"              
                "LDR     R0, [SP,#4]\n"               
                "LDR     R3, [R0]\n"                  
                "ADD     R3, R2, R3\n"                
                "CMP     R1, R3\n"                    
                "BCC     loc_FFD3D284\n"              
"loc_FFD3D4F4:\n"                                     
                                                  
                "LDR     R3, =0x6E81C\n"              
                "LDR     R0, =0x6E820\n"              
                "LDR     R2, [R3]\n"                  
                "LDR     R3, [R0,#4]\n"               
                "ADD     R2, R2, #0x18\n"             
                "MOV     R1, R2\n"                    
                "MOV     R2, #0\n"                    
                "CMP     R2, R3\n"                    
                "BHI     loc_FFD3D528\n"              
                "BNE     loc_FFD3D530\n"              
                "LDR     R3, [R0]\n"                  
                "CMP     R1, R3\n"                    
                "BLS     loc_FFD3D530\n"              
"loc_FFD3D528:\n"                                     
                                                  
                "MOV     R0, #0x80000005\n"           
                "B       loc_FFD3D6A4\n"              
"loc_FFD3D530:\n"                                     
                                                  
                "LDR     R1, =0x6E804\n"              
                "LDR     R0, =0x6E850\n"              
                "LDR     R3, [R1]\n"                  
                "LDR     R2, [R0]\n"                  
                "ADD     R3, R3, R2,LSL#4\n"          
                "ADD     R3, R3, R3,LSL#2\n"          
                "LDR     R12, =0x6E820\n"             
                "MOV     R3, R3,LSL#1\n"              
                "ADD     R3, R3, #0xA0\n"             
                "LDR     R2, [R12,#4]\n"              
                "MOV     R0, R3\n"                    
                "MOV     R1, #0\n"                    
                "CMP     R1, R2\n"                    
                "BHI     loc_FFD3D578\n"              
                "BNE     loc_FFD3D59C\n"              
                "LDR     R3, [R12]\n"                 
                "CMP     R0, R3\n"                    
                "BLS     loc_FFD3D59C\n"              
"loc_FFD3D578:\n"                                     
                "LDR     R4, =0x6E838\n"              
                "LDR     R1, [R4]\n"                  
                "CMP     R1, #0\n"                    
                "BNE     loc_FFD3D59C\n"              
                "MOV     R0, #0x3140\n"               
                "ADD     R0, R0, #8\n"                
                "BL      sub_FFD54E78\n"              
                "MOV     R3, #1\n"                    
                "STR     R3, [R4]\n"                  
"loc_FFD3D59C:\n"                                     
                                                  
                "LDR     R1, =0x6E804\n"              
                "LDR     R0, =0x6E850\n"              
                "LDR     R2, [R1]\n"                  
                "LDR     R3, [R0]\n"                  
                "LDR     R0, =0x6E828\n"              
                "ADD     R2, R2, R3,LSL#4\n"          
                "MVN     R3, #0x9F\n"                 
                "ADD     R2, R2, R2,LSL#2\n"          
                "ADD     R3, R3, #0x40000000\n"       
                "SUB     R3, R3, R2,LSL#1\n"          
                "LDR     R1, [R0,#4]\n"               
                "MOV     R4, R3\n"                    
                "MOV     R5, #0\n"                    
                "CMP     R1, R5\n"                    
                "BHI     loc_FFD3D5E8\n"              
                "BNE     loc_FFD3D60C\n"              
                "LDR     R3, [R0]\n"                  
                "CMP     R3, R4\n"                    
                "BLS     loc_FFD3D60C\n"              
"loc_FFD3D5E8:\n"                                     
                "LDR     R4, =0x6E838\n"              
                "LDR     R1, [R4]\n"                  
                "CMP     R1, #0\n"                    
                "BNE     loc_FFD3D60C\n"              
                "MOV     R0, #0x3140\n"               
                "ADD     R0, R0, #8\n"                
                "BL      sub_FFD54E78\n"              
                "MOV     R3, #1\n"                    
                "STR     R3, [R4]\n"                  
"loc_FFD3D60C:\n"                                     
                                                  
                "LDR     R3, =0x6E850\n"              
                "LDR     R0, =0x6E7EC\n"              
                "LDR     R2, [R3]\n"                  
                "LDR     R12, =0x6E7D4\n"             
                "LDR     R1, [R0]\n"                  
                "ADD     R3, R2, R2,LSL#2\n"          
                "ADD     R2, R2, R3,LSL#1\n"          
                "LDR     R0, [R12]\n"                 
                "RSB     R1, R2, R1\n"                
                "CMP     R0, R1\n"                    
                "BLS     loc_FFD3D65C\n"              
                "LDR     R4, =0x6E838\n"              
                "LDR     R1, [R4]\n"                  
                "CMP     R1, #0\n"                    
                "BNE     loc_FFD3D65C\n"              
                "MOV     R0, #0x3140\n"               
                "ADD     R0, R0, #8\n"                
                "BL      sub_FFD54E78\n"              
                "MOV     R3, #1\n"                    
                "STR     R3, [R4]\n"                  
"loc_FFD3D65C:\n"                                     
                                                  
                "LDR     R3, =0x6E828\n"              
                "LDR     R12, =0x6E81C\n"             
                "LDMIA   R3, {R1,R2}\n"               
                "LDR     R0, [R12]\n"                 
                "MOV     R4, #0\n"                    
                "MOV     R3, #0x18\n"                 
                "ADDS    R1, R1, R0\n"                
                "ADC     R2, R2, #0\n"                
                "ADDS    R1, R1, R3\n"                
                "ADC     R2, R2, R4\n"                
                "CMP     R2, #0\n"                    
                "BHI     loc_FFD3D698\n"              
                "BNE     loc_FFD3D6A0\n"              
                "CMP     R1, #0x40000000\n"           
         //     "BLS     loc_FFD3D6A0\n"        // -

                "B       loc_FFD3D6A0\n"        // +

"loc_FFD3D698:\n"                                     
                "MOV     R0, #0x80000007\n"           
                "B       loc_FFD3D6A4\n"              
"loc_FFD3D6A0:\n"                                     
                                                  
                "MOV     R0, #0\n"                    
"loc_FFD3D6A4:\n"                                     
                                                  
                "ADD     SP, SP, #0x14\n"             
                "LDMFD   SP!, {R4-R11,PC}\n"          

 );
}



void __attribute__((naked,noinline)) sub_FFD3C5AC_my(){
 asm volatile(
                "CMP     R2, #1\n"                    
                "STMFD   SP!, {R4-R7,LR}\n"           
                "MOV     R7, R0\n"                    
                "MOV     R6, R1\n"                    
                "MOVEQ   R3, #0x79\n"                 
                "STREQ   R3, [R6]\n"                  
                "LDMEQFD SP!, {R4-R7,PC}\n"           
                "LDR     R12, =0x6E538\n"             
                "LDR     R0, [R12]\n"                 
                "LDR     R3, =0x6E540\n"              
                "CMP     R0, #0\n"                    
                "LDR     R1, [R3]\n"                  
                "BEQ     loc_FFD3C5F4\n"              
                "LDR     R2, =0x6E544\n"              
                "LDR     R3, [R2]\n"                  
                "CMP     R3, #1\n"                    
                "BNE     loc_FFD3C608\n"              
                "B       loc_FFD3C5F8\n"              
"loc_FFD3C5F4:\n"                                     
                "LDR     R2, =0x6E544\n"              
"loc_FFD3C5F8:\n"                                     
                "MOV     R3, #0\n"                    
                "STR     R3, [R2]\n"                  
                "STR     R7, [R12]\n"                 
                "B       loc_FFD3C6C0\n"              
"loc_FFD3C608:\n"                                     
                "LDR     R2, =0x6E53C\n"              
                "LDR     R3, [R2]\n"                  
                "LDR     R5, =table1\n"   //+ 0xFFD3C41C      
                "ADD     R3, R3, R3,LSL#1\n"          
                "MOV     LR, R3,LSL#2\n"              
                "LDR     R2, [R5,LR]\n"               
                "LDR     R4, =table2\n"   //+ 0xFFD3C440      
                "RSB     R12, R2, R0\n"               
                "LDR     R3, [R4,LR]\n"               
                "CMP     R12, #0\n"                   
                "RSB     R0, R3, R0\n"                
                "BLE     loc_FFD3C66C\n"              
                "ADD     R3, R5, #4\n"                
                "LDR     R2, [R3,LR]\n"               
                "CMP     R2, R12\n"                   
                "ADDGE   R1, R1, #1\n"                
                "BGE     loc_FFD3C660\n"              
                "ADD     R3, R5, #8\n"                
                "LDR     R2, [R3,LR]\n"               
                "CMP     R2, R12\n"                   
                "ADDGE   R1, R1, #2\n"                
                "ADDLT   R1, R1, #3\n"                
"loc_FFD3C660:\n"                                     
            //  "CMP     R1, #0xE\n"    // -          
            //  "MOVGE   R1, #0xE\n"    // -          

                "CMP     R1, #0x1A\n"   // +      
                "MOVGE   R1, #0x1A\n"   // +      

                "B       loc_FFD3C6A4\n"              
"loc_FFD3C66C:\n"                                     
                "CMP     R0, #0\n"                    
                "BGE     loc_FFD3C6A4\n"              
                "ADD     R3, R4, #4\n"                
                "LDR     R2, [R3,LR]\n"               
                "CMP     R2, R0\n"                    
                "SUBLE   R1, R1, #1\n"                
                "BLE     loc_FFD3C69C\n"              
                "ADD     R3, R4, #8\n"                
                "LDR     R2, [R3,LR]\n"               
                "CMP     R2, R0\n"                    
                "SUBLE   R1, R1, #2\n"                
                "SUBGT   R1, R1, #3\n"                
"loc_FFD3C69C:\n"                                     
                "CMP     R1, #0\n"                    
                "MOVLT   R1, #0\n"                    
"loc_FFD3C6A4:\n"                                     
                                                  
                "LDR     R0, =0x6E540\n"              
                "LDR     R3, [R0]\n"                  
                "CMP     R1, R3\n"                    
                "LDRNE   R2, =0x6E544\n"              
                "MOVNE   R3, #1\n"                    
                "STRNE   R1, [R0]\n"                  
                "STRNE   R3, [R2]\n"                  
"loc_FFD3C6C0:\n"                                     
                "LDR     R3, =0x6E540\n"              
       //       "LDR     R1, =0x6088\n"    // -
                "LDR     R1, =video_mode\n"  //+       
                "LDR     R0, [R3]\n"                  
                "LDR     R2, =CompressionRateTable\n"  // + 0xFFD3C3E0
                "LDR     R12, [R1]\n"                 
                "LDR     R12, [R12]\n"    //+
                "LDR     LR, [R2,R0,LSL#2]\n"         
                "LDR     R3, =0x6E538\n"              
                "CMP     R12, #1\n"                   
                "STR     R7, [R3]\n"                  
                "STR     LR, [R6]\n"                  
         //     "MOVEQ   R3, #0xB\n"     // -

                "LDREQ   R3, =video_quality\n"   // +
                "LDREQ   R3, [R3]\n"             // +
                "LDREQ   R3, [R3]\n"             // +

                "STREQ   R3, [R6]\n"                  
                "BL      mute_on_zoom\n"     // +
                "LDMFD   SP!, {R4-R7,PC}\n"           
 );
}

